import { post, get } from '@/utils/http'
import type {IUsersType,UserListType,IAddUserFormType} from "@/typings/ladyType"
// 红娘用户列表
export const getUsersApi = (page = 1, query = '', size: number = 10) =>
  get<IUsersType>(`/api/lady?page=${page}&size=${size}${query}`)
// 检查账号是否已经存在
export const checkUserNameApi = (username: string) =>
  post<number>(`/api/ladycheckUsername`, { username })


// 添加用户到表格中
export const addUserApi = (userData: IAddUserFormType) =>
  post<UserListType>(`/api/lady`, userData)

// 根据用户id返回对应的用户记录数据
export const getUserIdToInfoApi = (userid: number) =>
  get<UserListType>(`/api/lady/${userid}`)
  
// 修改用户
export const editUserApi = (
  id: number,
  userData: Optional<IAddUserFormType, 'password'>
) => post<number>(`/api/lady/${id}`, userData)
